package com.situ.test;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.oas.annotations.EnableOpenApi;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

@EnableOpenApi
@Configuration
public class SwaggerConfiguration {
    // implements WebMvcConfigurer {

    @Value("${swagger.enable}")
    private Boolean enable;
    //@Autowired
    //TypeResolver resolver;
    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.OAS_30).pathMapping("/")
                // 定义是否开启swagger，false为关闭，可以通过变量控制
                .enable(enable)
                .apiInfo(new ApiInfoBuilder()
                        .title("标题：员工管理系统")
                        .description("描述：用于管理集团旗下公司的人员信息,具体包括部门管理,员工管理")
                        .contact(new Contact("胡文", "主页无", "986776@qq.com"))
                        .version("版本号:1.0")
                        .build())
                // .additionalModels( resolver.resolve(Hero.class),resolver.resolve(Towns.class) )
                .select()
                //.apis(RequestHandlerSelectors.basePackage("com.situ"))
                //.apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
                //.apis(RequestHandlerSelectors.withMethodAnnotation(Operation.class))
                .apis(RequestHandlerSelectors.any())
                .paths(PathSelectors.any())
                .build();
    }
}